package org.example.chapter5.mapper;

import org.apache.ibatis.annotations.*;
import org.example.chapter5.entity.Student;

@Mapper
public interface StudentMapper {
    @Select("select * from student where id = #{id}")
    Student findById(int id);

    @Select("select * from student where name = #{name}")
    Student findByName(String name);

    @Insert("INSERT INTO student (name,qq) VALUES (#{name},#{qq})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Student student);

    @Update("UPDATE student SET name = #{name}, qq = #{qq} WHERE id = #{id}")
    void update(Student student);

    @Delete("DELETE FROM student WHERE id = #{id}")
    void deleteById(int id);

}
